package day03;

public class HomeWork {
    public static void main(String[] args) {
        //1.运算符的练习：算术
        /**
         * -输出几个整数取模，验证结果
         * -声明两个整型变量，演示单独使用时的自增和自减
         * -声明几个整型变量，演示被使用时的自增和自减
         */
       /* System.out.println(5%2);
        System.out.println(5.0%2);
        System.out.println(2%5);

        int num1,num2;
        num1++;
        ++num2;
        System.out.println(num1);
        System.out.println(num2);
        num1--;
        --num1;
        System.out.println(num1);
        System.out.println(num2);*/
        /*int a=5,b=3,c,d;
        c = a++;
        d = ++b;
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);*/
        /*int a=5,b=3,c,d;
        c = a--;
        d = --b;
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);*/
        //1.运算符的拉逆袭：关系
        /**
         * -声明几个变量，演示最基本的>,<,>=,<=,==,!=操作
         * -演示关系运算符和算术运算符联合使用的效果
         */
        /*int a = 5,b = 10,c = 5;
        boolean b1 = b>a;
        System.out.println(b1);
        System.out.println(c<b);
        System.out.println(a>=c);
        System.out.println(b<=a);
        System.out.println(b==c);
        System.out.println(a!=c);

        System.out.println(a+c>10);
        System.out.println(b%2==0);
        System.out.println(c++>5);
        System.out.println(c++>5);*/
        //1.运算符的练习：逻辑
        /***
         * -声明三个整型变量，演示&&和||，演示！
         * -&&的演示要求：true+false、false+true、true+true、false+false
         * -||的演示要求：true+false、false+true、true+true、false+false
         * -！的演示要求：true、false
         * -演示短路&&与短路||
         */
        /*int a = 5,b = 10,c= 5;
        boolean b1 = b >=a && b<c;
        System.out.println(b1);
        System.out.println(b<=c && b>a);
        System.out.println(a==b && c>b);
        System.out.println(b!=c && a<b);

        System.out.println(b>=a || b<c);
        System.out.println(b<=c || b>a);
        System.out.println(b!=c || a<b);
        System.out.println(a==b || c>b);

        boolean b2 = !(a<b);
        System.out.println(b2);
        System.out.println(!(a>b));*/

        /*int a = 5, b = 10, c = 5;
        boolean b3 = a>b && c+++>2;
        System.out.println(b3);
        System.out.println(c);

        boolean b4 = a<b || c++>2;
        System.out.println(b4);
        System.out.println(c);*/

        //1.运算符的练习：赋值
        /**
         * -声明一个整型变量，演示扩展赋值+=，-=，*=，/=，%=的效果
         * -声明short型变量s，演示简单赋值运算的自增10，演示扩展赋值运算的自增10
         */
        int a = 5;
        a += 10;
        System.out.println(a);
        a *= 2;
        System.out.println(a);
        a /= 6;
        System.out.println(a);

        short s = 5;
        //s = s +10;
        s += 10;

        //运算符的练习：字符串连接
        /**
         * -声明整型变量age和字符串变量那，e，输出字符串连接结果
         * -输出几个数据的拼接，演示字符串连接的同化作用
         */
        int age = 7;
        System.out.println("age+");
        System.out.println(age);
        System.out.println("age+"+age);
        System.out.println("我的年龄是"+age);
        System.out.println("我今年"+age+"岁了");

        String name = "HuangJin";
        System.out.println("name="+name);
        System.out.println("大家好，我叫"+name);
        System.out.println("大家好，我叫"+name+",今年"+age+"岁了");

        //演示同化作用
        System.out.println(10+20+""+30);
        System.out.println(""+10+20+30);
        System.out.println(10+20+30+"");

        //1.运算符的练习：条件/三目
        /**
         * -声明并初始化整型变量，使用条件运算实现：若>0则给flag赋值为1，否则赋值为0
         * -声明两个整型变量，使用条件运算的实现：求着两个变量的最大值
         */

        int num = 5;
        int flag = num > 0?1:-1;
        System.out.println(flag);

        int a3 = 8,b = 5;
        int max = a3>b?a3:b;
        System.out.println("max="+max);

        //分支结构的练习：if扩展练习
        /**
         * 满500打8折
         * 判断成绩是否合法
         */
        double price = 300.0;
        if (price>=500){
            price *= 0.8;
        }
        System.out.println("最终消费金额为："+price);
        //判断成绩是否合法
        int score = 555;
        if (score>=0 && score <= 100){
            System.out.println("成绩合法");
        }
        System.out.println("继续执行");

        //分支结构的练习：if...else
        /**
         * -满足500打8折，不满500打9折
         * 判断成绩合法还是不合法
         */
        //满足500打8折，不满500打9折
        double price1 = 300.0;
        if (price1>=500){
            price1*=0.8;
        }else {
            price1*=0.9;
        }
        System.out.println("最终消费金额为"+price1);

        //判断成绩合法还是不合法
        int score1 = 95;
        if (score1>=0) {
            System.out.println(score+"是合法成绩");
        }else {
            System.out.println(score+"是不合法成绩");
        }

        //分支结构练习：if...else if
        /**
         * -满2000打5折，满1000不满2000打7折，满500不嘛1000打8折，不满5000打9折
         */
        double price2 = 5000.0;
        if (price2>=2000){
            price2*=0.5;
        }else if (price2>=1000){
            price2*=0.7;
        }else if (price2>=500){
            price2*=0.8;
        }else {
            price2*=0.9;
        }
        System.out.println("最终消费金额为："+price2);
    }
}
